package src.com.atguigu01.throwable;

import org.junit.Test;

import java.util.Date;
import java.util.Scanner;

/**
 * ClassName: ExceptionTest
 * Package: src.com.atguigu01.throwable
 * Description:
 *
 * @Author BuTang
 * @Create 2023/4/25 23:14
 * @Version 1.0
 */
public class ExceptionTest {
    //ArrayIndexOutOfException
    @Test
    public void test1(){
        int[] arr = new int[1];
        System.out.println(arr[1]);
    }

    @Test
    //NullPointerException
    public void test2() {
        String s = "hello";
        s= null;
        System.out.println(s.toString());
    }

    @Test
    public void test3(){
        //ClassNCastException
        Object obj = new String();
        Date d = (Date) obj;

    }
    //NumberFormatException
    @Test
    public void test5(){
        String s = "1233";
        int i =Integer.parseInt(s);
    }
    //InputMismatchException
    @Test
    public void test4(){
        Scanner sca = new Scanner(System.in);
        int i =  sca.nextInt();
    }
    //ArithmeticException
    @Test
    public void test6(){
        int i = 10 / 0;
    }
}


